package com.maddox.relax.model;

import java.util.Objects;

/**
 * @author Maddox
 * 2021-11-30
 * 展示文本的实体实现 示例
 * 必须重写equals 和 hashcode方法
 * 必须重写equals 和 hashcode方法
 * 必须重写equals 和 hashcode方法
 * 必须重写equals 和 hashcode方法
 */
public class DemoModel implements DataModel {

    public int id;//数据id
    public String content;//数据内容
    public boolean selected;//数据是否选中

    public DemoModel() {
    }

    public DemoModel(int id, String content, boolean selected) {
        this.id = id;
        this.content = content;
        this.selected = selected;
    }

    @Override
    public String getText() {
        return content;
    }

    @Override
    public boolean getSelected() {
        return selected;
    }

    @Override
    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    @Override
    public String toString() {
        return "DemoModel{" +
                "id=" + id +
                ", content='" + content + '\'' +
                ", selected=" + selected +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DemoModel demoModel = (DemoModel) o;
        return id == demoModel.id && Objects.equals(content, demoModel.content);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, content);
    }
}
